package com.thread.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Thread3 implements Callable<String> {
    @Override
    public String call(){
        return Thread.currentThread().getName();
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService ser = Executors.newFixedThreadPool(3);

        for (int i = 0; i < 5; i++) {
            System.out.println(ser.submit(new Thread3()).get());
        }
        //使用Callable需要手动关闭线程
        ser.shutdown();
    }
}
